package com.app.fk.mensa;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper{

	private static final String DATABASE_NAME = "mensa.db";
	public static final String WOCHE = "week";
	public static final String MONTAG_MENUE_1 = "mo1";
	public static final String MONTAG_MENUE_2 = "mo2";
	public static final String MONTAG_MENUE_3 = "mo3";
	public static final String DIENSTAG_MENUE_1 = "di1";
	public static final String DIENSTAG_MENUE_2 = "di2";
	public static final String DIENSTAG_MENUE_3 = "di3";
	public static final String MITTWOCH_MENUE_1 = "mi1";
	public static final String MITTWOCH_MENUE_2 = "mi2";
	public static final String MITTWOCH_MENUE_3 = "mi3";
	public static final String DONNERSTAG_MENUE_1 = "do1";
	public static final String DONNERSTAG_MENUE_2 = "do2";
	public static final String DONNERSTAG_MENUE_3 = "do3";
	public static final String FREITAG_MENUE_1 = "fr1";
	public static final String FREITAG_MENUE_2 = "fr2";
	public static final String FREITAG_MENUE_3 = "fr3";
	public static final String TABLE_NAME = "menues";
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, 4);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		try{
			db.execSQL("CREATE TABLE "+ TABLE_NAME +" (_id INTEGER PRIMARY KEY AUTOINCREMENT,"+ WOCHE +" NUMBER, "+MONTAG_MENUE_1+" TEXT, "+MONTAG_MENUE_2+" TEXT, "+MONTAG_MENUE_3+" TEXT, "+DIENSTAG_MENUE_1+" TEXT , "+DIENSTAG_MENUE_2+" TEXT, "+DIENSTAG_MENUE_3+" TEXT, "+MITTWOCH_MENUE_1+" TEXT, "+MITTWOCH_MENUE_2+" TEXT, "+MITTWOCH_MENUE_3+" TEXT, "+DONNERSTAG_MENUE_1+" TEXT, "+DONNERSTAG_MENUE_2+" TEXT, "+DONNERSTAG_MENUE_3+" TEXT, "+FREITAG_MENUE_1+" TEXT, "+FREITAG_MENUE_2+" TEXT, "+FREITAG_MENUE_3+" TEXT);");
		}
		catch(Exception e)
		{
			e.getMessage();
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	//	android.util.Log.v("Constants", "Upgrading database, which will destroy all old data");
		try{
		db.execSQL("DROP TABLE "+ TABLE_NAME);
		}catch(Exception e)
		{
			e.getMessage();
		}
		onCreate(db);
		
	}
	
	

}
